import { defineStore } from 'pinia'

export type UserLoginRes = {
  desc: string
  realName: string
  token: string
  userId: string
  username: string
  avatar: string
  email: string
  phone: string
}

type UserStoreState = {
  user: UserLoginRes | null
}

type UserStoreAction = {
  login(userInfo: UserLoginRes): void
}

export const useUserStore = defineStore<string, UserStoreState, {}, UserStoreAction>('userStore', {
  state: () => ({
    user: null,
    menuList: []
  }),
  actions: {
    login(userInfo: UserLoginRes) {
      this.user = userInfo
    }
  }
})
